import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    goodInfo: []
  },
  mutations: {
    GETGOOFINFO(state, value) {
      state.goodInfo = value
    }
  },
  actions: {
    getGoodInfo(context, value) {
      let url='http://127.0.0.1:8888/api/private/v1/goods/'+value
      console.log( url)
      axios.get(url).then(function (response) {
        console.log('获取成功', response.data)
        context.commit('GETGOOFINFO', response.data)
      }).catch(function (error) {
        console.log('获取失败', error)
      })
    }
  },
})
